package com.itts.middle.modules.project.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.itts.common.entity.Project;
import com.itts.middle.utils.sortUtil;
import com.sun.xml.bind.v2.model.core.ID;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public interface ProjectService extends IService<Project> {

    List<Project> selectList();

    /**
     * todo defult 关键字
     */
    default <T> List<T> sort(List<T> list,String o){
        System.out.println("jdk1.8新特性, 可以在接口中方法的实现"); //实现类无需实现, 直接调用,
        /*Collections.sort(list, new Comparator<Project>() {
            @Override
            public int compare(Project o1, Project o2) {
                if (o1.getId()>o2.getId()){
                    return -1;
                }
                if (o1.getId()<o2.getId()){
                    return 1;
                }
                return 0;
            }
        });*/

        //id 必须为 实体类 int类型的字段
        List<T> result = new sortUtil().sort(list, o);
        return result;
    }
}
